<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

	<f:view>
		<f:loadBundle basename="tvseries.Messages" var="msgs" />

		<head>
			<base href="<%=basePath%>"/>

			<title><h:outputText value="#{msgs['app.title']}" /></title>

			<meta http-equiv="pragma" content="no-cache">
			<meta http-equiv="cache-control" content="no-cache">
			<meta http-equiv="expires" content="0">
			<meta http-equiv="description" content="<h:outputText value="#{msgs['app.description']}"/>">
			<link rel="stylesheet" type="text/css" href="<%=basePath%>styles.css">
		</head>

		<body>
			<h:form id="main">
				<h:panelGrid align="center" columns="2" styleClass="mainview" headerClass="pageHeader" footerClass="pageFooter"
					columnClasses="menuColumn, contentColumn">

					<f:facet name="header">
						<f:subview id="header">
							<c:import url="/view/header.jsp" />
						</f:subview>
					</f:facet>

					<f:subview id="menu">
						<c:import url="/view/menu.jsp" />
					</f:subview>

					<f:subview id="content">
						<%/* CONTENT BEGIN */%>
						<h:panelGrid columns="1" styleClass="content" headerClass="contentHeader" footerClass="contentFooter">

							<f:facet name="header">
								<h:panelGroup>
									<h:outputText value="#{msgs['view.series.list.title']}" styleClass="title" />
									<f:verbatim>
										<hr />
									</f:verbatim>
									<h:messages />
								</h:panelGroup>
							</f:facet>

							<h:dataTable id="seriesList" styleClass="dataTable" rowClasses="boxedRow" columnClasses="titleColumn,lastUpdateColumn,codeColumn,selectColumn" footerClass="centerColumn" frame="border" value="#{tvManager.series}" var="series">
								<h:column>
									<f:facet name="header">
										<h:outputText value="#{msgs['view.series.list.column.name']}"/>
									</f:facet>
									<h:commandLink value="#{series.title}" action="#{tvManager.viewSeries}">
										<f:param name="seriesId" value="#{series.id}"/>
									</h:commandLink>
								</h:column>
								<h:column>
									<f:facet name="header">
										<h:outputText value="#{msgs['view.series.list.column.lastUpdate']}"/>
									</f:facet>
									<h:outputText value="#{series.lastUpdate}"/>
								</h:column>
								<h:column>
									<f:facet name="header">
										<h:outputText value="#{msgs['view.series.list.column.imdb']}"/>
									</f:facet>
									<h:outputLink value="#{series.imdbUrl}"><h:outputText value="#{series.id}"/></h:outputLink>
								</h:column>
								<h:column>
									<f:facet name="header">
										<h:panelGroup>
											<h:commandLink styleClass="commandLink" id="selectAllCommand" value="select all" action="#{tvManager.selectAllSeries}" immediate="true"/>
											<f:verbatim><br/></f:verbatim>
											<h:commandLink styleClass="commandLink" id="deselectAllCommand" value="deselect all" action="#{tvManager.deselectAllSeries}" immediate="true"/>
										</h:panelGroup>
									</f:facet>
									<h:selectBooleanCheckbox id="policySelect" value="#{series.selected}"/>
								</h:column>

							</h:dataTable>
							
							<f:facet name="footer">
								<h:panelGroup>
									<h:commandButton id="updateButton" value="update selected series" action="#{tvManager.updateSelectedSeries}"/>
									<h:commandButton id="deleteButton" value="delete selected series" action="#{tvManager.deleteSelectedSeries}"/>
								</h:panelGroup>
							</f:facet>

						</h:panelGrid>
						<%/* CONTENT END */%>
					</f:subview>

					<f:facet name="footer">
						<f:subview id="footer">
							<c:import url="/view/footer.jsp" />
						</f:subview>
					</f:facet>
				</h:panelGrid>
			</h:form>
		</body>
	</f:view>

</html>
